<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>53-jQuery-替换节点</title>
</head>
<body>
    <button>替换按钮</button>
    <div>
        <h1>我是标题1</h1>
        <h2>我是标题2</h2>
    </div>

    <script src="./js/jquery-1.12.4.js"></script>
    <script>
      $(function(){
          $('button').click(function(){
              //1.创建一个h6标题元素
              var $h6 = $('<h6>我是标题6</h6>')
              //2.将页面中的h2标题替换为h6标题元素
              $('h2').replaceWith($h6)
              //3.将页面中h2标题为h6
              $h6.replaceAll('h2')
          })
      })
    </script>
</body>
</html>